import request from '@/utils/request'
import { AxiosPromise } from 'axios'

enum Api {
  list = '/camera/list',
  delete = '/camera/delete',
  batchDelete = '/camera/batchDelete',
  add = '/camera/add',
  edit = '/camera/edit',
  detail = '/camera/detail',
  changeStatus = '/camera/changeStatus',
  bindStation = '/camera/bindStation',
  logs = '/camera/logs',
}

// 获取列表
export const cameraList = (data: any): AxiosPromise<any> => {
  return request({
    url: Api.list,
    method: 'post',
    data,
  })
}

// 获取日志列表
export const cameraLogList = (data: any): AxiosPromise<any> => {
  return request({
    url: Api.logs,
    method: 'post',
    data,
  })
}

// 删除
export const cameraDelete = (data: any) => {
  return request({
    url: Api.delete,
    method: 'post',
    data,
  })
}
// 批量删除
export const cameraBatchDelete = (data: (string | number)[]) => {
  return request({
    url: Api.batchDelete,
    method: 'post',
    data,
  })
}

// 编辑、保存
export const cameraSave = (data: any) => {
  return request({
    url: data.id ? Api.edit : Api.add,
    method: 'post',
    data,
  })
}

// 绑定
export const bindStation = (data: any) => {
  return request({
    url: Api.bindStation,
    method: 'post',
    data,
  })
}

// 获取设备详情
export const cameraDetail = (data) => {
  return request({
    url: Api.detail,
    method: 'post',
    data,
  })
}

// 状态修改
export function changeStatus(id: string | number, status: number) {
  const data = {
    id,
    status,
  }
  return request({
    url: Api.changeStatus,
    method: 'post',
    data,
  })
}
